﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WPF_for_Auth.ViewModel;

namespace WPF_for_Auth
{
    internal partial class MvvmLoad : ObservableObject
    {
        /// <summary>
        /// 当前状态 
        /// </summary>
        [ObservableProperty]
        private NowStatus app_NowStatus;
        /// <summary>
        /// 菜单状态
        /// </summary>
        [ObservableProperty]
        private MenuStatus app_MenuStatus;

        [ObservableProperty]
        private PageStatus app_PageStatus;

        [ObservableProperty]
        private DbOperate app_DbOperate;

        public static MvvmLoad mvvm { get; } = new MvvmLoad(); // 静态实例，确保全局唯一 

        public MvvmLoad()
        {
            App_NowStatus = new NowStatus(this); // 初始化 NowStatus 实例
            App_MenuStatus = new MenuStatus(this); // 初始化 MenuStatus 实例
            App_PageStatus = new PageStatus(this); // 初始化 PageStatus 实例
            App_DbOperate = new DbOperate(this); // 初始化 DbOperate 实例
        }

        /// <summary>
        /// 与操作页面变化相关的按钮命令
        /// </summary>
        /// <param name="parameter"></param>
        [RelayCommand]
        public void ButtonClick_ControlPage(string parameter)
        {
            app_PageStatus.ChoosePage(parameter);
        }

        /// <summary>
        /// 执行操作按钮命令
        /// </summary>
        /// <param name="parameter"></param>
        [RelayCommand]
        public void ButtonClick_DoAction(string parameter)
        {            
            app_DbOperate.OperationAction(parameter);
        }
    }
}
